import java.util.ArrayList;
import java.util.List;

// 2783915460
public class P24 {
	private static List<Integer> list = new ArrayList<Integer>();
	private static int max = 1000000;
	public static void createPermutation(String t, int index) {
		//System.out.println(t);
		if (index == 10) {
			if (--max == 0) {
				System.out.println(t);	
			}
			return;
		}
		
		List<Integer> usedList = new ArrayList<Integer>();
		byte[] b = t.getBytes();
		for (int j = 0; j < b.length; j++) {
			usedList.add(b[j] - 48);
		}
		
		index++;
		for (int i = 0; i < list.size(); i++) {
			if (!usedList.contains(i)) {
				createPermutation(t + String.valueOf(list.get(i)), index);		
			}
		}
	}
	
	public static void main(String[] args) {
		int n = 10;
		for (int i = 0; i < n; i++) {
			list.add(i);		
		}
		createPermutation("", 0);		
	}
}